package simple13;

import simple13.discount.Discount;
import simple13.discount.FullDiscount;
import simple13.discount.NewerDiscount;
import simple13.discount.SecondDiscount;
import simple13.factory.AppleFactory;
import simple13.factory.BananaFactory;
import simple13.factory.OrangeFactory;
import simple13.fruit.Fruit;
import simple13.template.OnLineShopping;
import simple13.template.ShoppingCart;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

//策略模式
public class Simple {
    private static Map<String, Discount> map = new HashMap<>();

    static {
        map.put("full",new FullDiscount());
        map.put("second",new SecondDiscount());
        map.put("new",new NewerDiscount());
    }
    public static void main(String[] args) {

        List<Fruit> products = new ArrayList<>();
        products.add(new AppleFactory().getFruit());
        products.add(new OrangeFactory().getFruit());
        products.add(new BananaFactory().getFruit());
        ShoppingCart cart = new OnLineShopping(products);
//        优惠政策
//        cart.setDiscount(new FullDiscount());
        cart.setDiscount(map.get("second"));
        cart.submitOrder();
    }
}
